﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using SmartMD.DataModel.Entity;
using SmartMD.Manager.Common;


namespace SmartMD.Manager.SysInfo
{
    /// <summary>
    /// Interaction logic for ExamItemDefine.xaml
    /// </summary>
    public partial class ExamItemDefine : UserControl
    {
       
        private ExamItemInfo _dataSource;
        public ExamItemInfo DataSource
        {
            get
            {
                return _dataSource;
            }
            set
            {
                _dataSource = value;
                this.DataContext = value;
            }
        }

        public ExamItemDefine()
        {
            InitializeComponent();
            
        }

        private void CreateCloumn_Click(object sender, RoutedEventArgs e)
        {
            IndiceDefine column = new IndiceDefine();
            column.Id = System.Guid.NewGuid().ToString();
            if (DataSource != null)
            {
                if ((sender as Button).Tag == null)
                    DataSource.columns.Add(column);
                else
                {
                    int index = DataSource.columns.IndexOf((sender as Button).Tag as IndiceDefine);
                    DataSource.columns.Insert(index, column);
                }
            }
        }
        private void DeleteCloumn_Click(object sender, RoutedEventArgs e)
        {
            if (DataSource != null)
            {
                DataSource.columns.Remove((sender as Button).Tag as IndiceDefine);
            }
        }

      /*  private void InitializedDataType(object sender, EventArgs e)
        {
            List<ComboBoxValueItem> datasource = new List<ComboBoxValueItem>();
            datasource.Add(new ComboBoxValueItem { Name = "数值型", Value = "number" });
            datasource.Add(new ComboBoxValueItem { Name = "字符型", Value = "string" });
            datasource.Add(new ComboBoxValueItem { Name = "时间型", Value = "datetime" });
            datasource.Add(new ComboBoxValueItem { Name = "字节型", Value = "bytes" });
            datasource.Add(new ComboBoxValueItem { Name = "影像", Value = "image" });

            (sender as ComboBox).ItemsSource = datasource;
        
        } */
        private void InitializedIndiceLevel(object sender, EventArgs e)
        {
            List<ComboBoxValueItem> datasource = new List<ComboBoxValueItem>();

            datasource.Add(new ComboBoxValueItem { Name = "必需", Value = "necessary" });
            datasource.Add(new ComboBoxValueItem { Name = "一般", Value = "normal" });
            datasource.Add(new ComboBoxValueItem { Name = "次要", Value = "minor" });

            (sender as ComboBox).ItemsSource = datasource;
        }

        private void CmbItemType_Initialized(object sender, EventArgs e)
        {
            List<ComboBoxValueItem> datasource = new List<ComboBoxValueItem>();

            datasource.Add(new ComboBoxValueItem { Name = "检验项目", Value = "ExamItem" });
            datasource.Add(new ComboBoxValueItem { Name = "检查项目", Value = "CheckItem" });
         
            (sender as ComboBox).ItemsSource = datasource;
        }

        private void cbIsEnabled_Checked(object sender, RoutedEventArgs e)
        {
            this.DataSource.IsEnabled = (sender as CheckBox).IsChecked.ToString();
        }
      
    }
}
